<?php
/**
 * Eren Framework
 * 
 * Used to Reigst Global Variable
 * 
 * @category System
 * @author Manu Soros Leu
 * @copyright manusoros@gmail.com
 */

class Eren_Registry
{
    
    /**
     * Used to Store Global Variable
     * 
     * @var array
     */
    private static $_params = array();
    
    /**
     * Set Global Variable
     * 
     * @param string $key
     * @param int|string|array|object $value
     * @throws Eren_Exception
     */
    public static function set($key, $value)
    {
        if(is_array($key) || empty($key)){
            throw new Eren_Exception('The param of Eren_Registry::set cant be array or null');
        }
        self::$_params[$key] = $value;
    }
    
    /**
     * Get Global Variable
     * 
     * @param string $key
     * @param int|string|array|object $default
     * @throws Eren_Exception
     * @return int|string|array|object
     */
    public static function get($key, $default = NULL)
    {
        if(is_array($key) || empty($key)){
            throw new Eren_Exception('The param of Eren_Registry::get cant be array or null');
        }
        if(isset(self::$_params[$key])){
            return self::$_params[$key];
        }
        return $default;
    }
    
    /**
     * Get All Global Variables
     * 
     * @return array
     */
    public static function getAll()
    {
        return self::$_params;
    }
}